/* eslint-disable react/jsx-no-duplicate-props */
import React, {Component} from 'react'
import {Button, Form, Input} from 'antd';
import {connect} from "react-redux";


class Add extends Component {

    onFinish = (values) => {
        if (values) {
            this.props.add(values).then(res => {
                this.props.list({page: 1, size: 10})
            })
        }
        this.props.handleCancel()

    };

    onFinishFailed = (errorInfo) => {

    };

    render() {
        return (
            <div>
                <Form
                    name="basic"
                    labelCol={{span: 6}}
                    wrapperCol={{span: 14}}
                    onFinish={this.onFinish}
                    onFinishFailed={this.onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item
                        label="圈子类型："
                        name="typeName"
                        rules={[{required: true, message: '请输入圈子类型!'}]}
                    >
                        <Input/>
                    </Form.Item>

                    <Form.Item
                        label="备注："
                        name="remarks"
                    >
                        <Input.TextArea/>
                    </Form.Item>

                    <Form.Item wrapperCol={{offset: 8, span: 16}}>
                        <Button type="primary" htmlType="submit">
                            保存
                        </Button>
                        <Button type="primary" htmlType="reset" style={{marginLeft: 30}}>
                            重置
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        )
    }
}

const mapState = state => ({
    ...state.circleType

});

const mapDispatch = dispatch => ({
    ...dispatch.circleType
})

export default connect(mapState, mapDispatch)(Add);